from django.contrib import admin

# Register your models here.
from import_export.admin import ImportExportModelAdmin, ExportMixin
from polls.models import Address, TRXValue
from polls.resources import TRXvalueResource


class TRXValueAdmin(ExportMixin, admin.ModelAdmin):
    readonly_fields = [field.name for field in TRXValue._meta.fields]
    actions = None
    resource_class = TRXvalueResource

    def has_add_permission(self, request):
        return False

    def has_delete_permission(self, request, obj=None):
        return False

    list_display = ['_address', 'withdraw_wallet']

    def _address(self, obj):
        return obj.address.address
    _address.short_description = '地址'

    search_fields = ['address__address']

    def get_list_display_links(self, request, list_display):
        pass


admin.site.register(Address)
admin.site.register(TRXValue, TRXValueAdmin)
